<?php
namespace App\Core;

class Container {
    protected $bindings = [];

    // 绑定类或接口
    public function bind($abstract, $concrete) {
        $this->bindings[$abstract] = $concrete;
    }

    // 解析依赖
    public function resolve($abstract) {
        if (isset($this->bindings[$abstract])) {
            $concrete = $this->bindings[$abstract];
            if (is_callable($concrete)) {
                return $concrete($this);
            }
            return new $concrete();
        }
        throw new \Exception("Dependency {$abstract} not found");
    }
}